﻿' *
' * RM2 Character Generator
' * Copyright (C) 2009 James Culshaw
' * 
' * This program is free software; you can redistribute it and/or modify it under the terms of 
' * the GNU General Public License as published by the Free Software Foundation; either version 2 
' * of the License, or (at your option) any later version.
' * 
' * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
' * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
' * See the GNU General Public License for more details.
' * 
' * You should have received a copy of the GNU General Public License along with this program; 
' * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
' *

Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports RMCharGen.Data

'''<summary>
'''This is a test class for SkillTest and is intended
'''to contain all SkillTest Unit Tests
'''</summary>
<TestClass()> _
Public Class SkillTest


    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(ByVal value As TestContext)
            testContextInstance = Value
        End Set
    End Property

#Region "Additional test attributes"
    '
    'You can use the following additional attributes as you write your tests:
    '
    'Use ClassInitialize to run code before running the first test in the class
    '<ClassInitialize()>  _
    'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
    'End Sub
    '
    'Use ClassCleanup to run code after all tests in a class have run
    '<ClassCleanup()>  _
    'Public Shared Sub MyClassCleanup()
    'End Sub
    '
    'Use TestInitialize to run code before running each test
    '<TestInitialize()>  _
    'Public Sub MyTestInitialize()
    'End Sub
    '
    'Use TestCleanup to run code after each test has run
    '<TestCleanup()>  _
    'Public Sub MyTestCleanup()
    'End Sub
    '
#End Region


    '''<summary>
    '''A test for TypeTwo
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub TypeTwoTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "Type Two"
        Dim actual As String
        target.TypeTwo = expected
        actual = target.TypeTwo
        Assert.AreEqual(expected, actual)

    End Sub

    '''<summary>
    '''A test for TypeOne
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub TypeOneTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "Type One"
        Dim actual As String
        target.TypeOne = expected
        actual = target.TypeOne
        Assert.AreEqual(expected, actual)

    End Sub

    '''<summary>
    '''A test for StatTwo
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub StatTwoTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "EM"
        Dim actual As String
        target.StatTwo = expected
        actual = target.StatTwo
        Assert.AreEqual(expected, actual)

    End Sub

    '''<summary>
    '''A test for StatThree
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub StatThreeTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "Pr"
        Dim actual As String
        target.StatThree = expected
        actual = target.StatThree
        Assert.AreEqual(expected, actual)

    End Sub

    '''<summary>
    '''A test for StatOne
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub StatOneTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "In"
        Dim actual As String
        target.StatOne = expected
        actual = target.StatOne
        Assert.AreEqual(expected, actual)

    End Sub

    '''<summary>
    '''A test for StatOne
    '''</summary>
    <TestMethod(), _
     ExpectedException(GetType(InvalidStatTypeException)), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub StatOneFailTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "IN"
        target.StatOne = expected

    End Sub

    '''<summary>
    '''A test for StatOne
    '''</summary>
    <TestMethod(), _
     ExpectedException(GetType(InvalidStatTypeException)), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub StatTwoFailTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "PR"
        target.StatTwo = expected

    End Sub

    '''<summary>
    '''A test for StatOne
    '''</summary>
    <TestMethod(), _
     ExpectedException(GetType(InvalidStatTypeException)), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub StatThreeFailTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "Em"
        target.StatThree = expected

    End Sub

    '''<summary>
    '''A test for Name
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub NameTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As String = "Skill Name"
        Dim actual As String
        target.Name = expected
        actual = target.Name
        Assert.AreEqual(expected, actual)

    End Sub

    '''<summary>
    '''A test for IsPrimary
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub IsPrimaryTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim expected As Boolean = True
        Dim actual As Boolean
        target.IsPrimary = expected
        actual = target.IsPrimary
        Assert.AreEqual(expected, actual)

    End Sub

    '''<summary>
    '''A test for Skill Constructor
    '''</summary>
    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub SkillConstructorTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Assert.AreEqual(String.Empty, target.Name)
        Assert.AreEqual(String.Empty, target.StatOne)
        Assert.AreEqual(String.Empty, target.StatTwo)
        Assert.AreEqual(String.Empty, target.StatThree)
        Assert.AreEqual(String.Empty, target.TypeOne)
        Assert.AreEqual(String.Empty, target.TypeTwo)
        Assert.IsFalse(target.IsPrimary)

    End Sub



    <TestMethod(), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub ValidateStatTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim stat As String = String.Empty
        target.ValidateStat(stat)
        stat = "CO"
        target.ValidateStat(stat)
        stat = "AG"
        target.ValidateStat(stat)
        stat = "SD"
        target.ValidateStat(stat)
        stat = "Me"
        target.ValidateStat(stat)
        stat = "Re"
        target.ValidateStat(stat)
        stat = "St"
        target.ValidateStat(stat)
        stat = "Qu"
        target.ValidateStat(stat)
        stat = "Pr"
        target.ValidateStat(stat)
        stat = "In"
        target.ValidateStat(stat)
        stat = "EM"
        target.ValidateStat(stat)

    End Sub

    <TestMethod(), _
     ExpectedException(GetType(InvalidStatTypeException)), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub ValidateStatFailTest()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim stat As String = "AA"
        target.ValidateStat(stat)

    End Sub

    <TestMethod(), _
     ExpectedException(GetType(InvalidStatTypeException)), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub ValidateStatFailTest2()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim stat As String = "Re "
        target.ValidateStat(stat)

    End Sub

    <TestMethod(), _
     ExpectedException(GetType(InvalidStatTypeException)), _
     DeploymentItem("RMCharGen.exe")> _
    Public Sub ValidateStatFailTest3()

        Dim target As Skill_Accessor = New Skill_Accessor()
        Dim stat As String = " CO"
        target.ValidateStat(stat)

    End Sub

End Class
